home *** CD-ROM | disk | FTP | other *** search
/ Collection of Tools & Utilities / Collection of Tools and Utilities.iso / ada / c01oop.zip / ADAWKBK / SOL2-8.ADA < prev    next >
Text File  |  1992-08-25  |  706b  |  38 lines

  1. -- Problem 2.8
  2. -- by Rick Conn
  3. with Text_IO;
  4. procedure Main is
  5.  
  6.   package Float_IO is new Text_IO.Float_IO (FLOAT);
  7.  
  8.   type FARRAY is array (1..100) of FLOAT;
  9.  
  10.   type REC is record
  11.     Count  : NATURAL;
  12.     Vector : FARRAY;
  13.   end record;
  14.   type REC_PTR is access REC;
  15.  
  16.   P, P2 : REC_PTR;
  17.  
  18.   procedure Display (Ptr : in REC_PTR) is
  19.   begin
  20.     for I in 1 .. Ptr.Count loop
  21.       Float_IO.Put (Ptr.Vector(I), 5, 5, 0);
  22.     end loop;
  23.     Text_IO.New_Line;
  24.   end Display;
  25.  
  26. begin -- Main
  27.  
  28.   P := new REC;
  29.   P2 := new REC;
  30.   P.Count := 4;
  31.   P.Vector(1..4) := (2.2, 1.1, 3.3, 4.4);
  32.   P2.Count := 2;
  33.   P2.Vector(1..2) := (10.2, 12.2);
  34.   Display (P);
  35.   Display (P2);
  36.  
  37. end Main;
  38.